<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *售后列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';

$tabs=array(
	array('op'=>'list','title'=>'口碑排行'),
);
$batch=array(
	//array('type'=>'post','url'=>'/member.list/setstore/','title'=>'一键归属门店'),
);
//售后列表
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=array();
	$params=array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']);
	if($_RQ['status']!='all'){
		$params['status']=intval($_RQ['status']);
	}
	$return['params']['status']=$_RQ['status'];
	if($_RQ['storeid']){
		$params['storeid']=intval($_RQ['storeid']);
		$return['params']['storeid']=$_RQ['storeid'];
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.$_RQ['title'].'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile']=$_RQ['mobile'];
		$return['params']['mobile']=$_RQ['mobile'];
	}
	$from_yonghuids=pdo_getall('jy_yxw_member',array('koubei_storeid'=>$_SESSION['storeid'],'from_yonghuid >'=>0,'uniacid'=>$_SESSION['uniacid']),array('from_yonghuid'),'from_yonghuid');
	if($from_yonghuids){
		$from_yonghuids=array_keys($from_yonghuids);
	}else{
		$from_yonghuids=-1;
	}
	$params['id']=$from_yonghuids;
	$pindex = max(1, intval($_RQ['page']));
	$psize = $_RQ['psize']?:50;
	$list=pdo_getslice('jy_yxw_yonghu',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['member']=$this->model('yonghu')->member_show($item['id']);
			$item['num']=pdo_count('jy_yxw_member',array('from_yonghuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid']),'id');
			$item['baonum']=pdo_count('jy_yxw_member',array('from_yonghuid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'status'=>array(10,11,12,13,14,15,16,17,18,19,20)),'id');
		}
	}
	paixu($list,'num','desc');
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	//页面显示设置
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：
		</br>1、这里显示本门店的口碑排行情况！
		','del_message'=>'确认删除该记录吗？','total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('title'=>'姓名/电话','type'=>'img_string',
			'data'=>array(
				array('title'=>'姓名：','name'=>'title'),
				array('title'=>'电话：','name'=>'mobile')
				)
			),
			array('name'=>'sn','title'=>'编号','type'=>'string'),
			array('name'=>'classid','title'=>'售后群','type'=>'select','options'=>'class'),
			array('name'=>'num','title'=>'口碑量','type'=>'string'),
			array('name'=>'baonum','title'=>'口碑成交','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),'action'=>array(
			//array('type'=>'model','op'=>'setstore','title'=>'修改门店'),
		),'batch'=>$batch),
		'search'=>array(
			array('type'=>'string','width'=>'15','title'=>'手机号','name'=>'mobile','help'=>''),
			array('type'=>'string','width'=>'15','title'=>'售后名称','name'=>'title','help'=>''),
			//array('name'=>'status','width'=>'15','title'=>'状态','type'=>'radio','options'=>'status'),
		),
	);
	$return['class']=$this->getall('class',array('storeid'=>$_SESSION['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['status']=$this->yonghu_status;
	$return['jibie_type']=$this->member_jibie_type;
	$return['from_type']=$this->member_from_type;
	$return['htmls']=$htmls;
	exi($return);
}